/**
 * On domReady 
 */
$(function(){

	createList(".event-list");
	$("#button-delete").click(function(){
		pressDeleteButton();
	});

	$("#button-create").click(function(){
		pressCreateButton();
	});

	
});


/**
 * This function press the create button
 */
function pressCreateButton() {
	pressPlusOneButton('button-create',"document.location.href='/event/new';");
}

function addGuest() {
	var newGuest = $($('input.guest')[0]).clone();
	var numberOfGuest = $('input.guest').length;
	newGuest.attr('name','userGuests['+numberOfGuest+']');
	newGuest.attr('id','userGuests'+numberOfGuest+'');
	newGuest.insertAfter($('input.guest')[numberOfGuest-1]);
}

function pressDeleteButton() {
	if (selected==-1) {
		pressPlusOneButton('button-delete',"");
		return false;
	} else {
		pressPlusOneButton('button-delete',"document.location.href='/event/delete/"+selected+"';");
		return false;
	}
	
}